/**
 * 文字段落展开代码
 *
 * 用例：
 * <p class="short_info">原来的时候... <a href="#">[更多]</a></p>
 * <p class="long_info">原来的时候，自从用了加多宝以后，气色好了，精神也上去了。 <a href="#">[更多]</a></p>
 *
 */
(function(){
    $('p.short_info a').live('click', function(){
        clickHandle(this, true);
        return false;
    });

    $('p.long_info a').live('click', function(){
        clickHandle(this, false);
        return false;
    });

    function clickHandle(self, isShort){
        var paragraph = findParagraph(self);
        if (!paragraph) return false;
        var brother = paragraph;
        var brotherClassName = isShort ? 'long_info' : 'short_info';
        var action = isShort ? 'nextSibling' : 'previousSibling';
        var isCorrect = false;
        while(brother = brother[action]){
            if (brother.className && brother.className.replace(brotherClassName, '') != brother.className){
                isCorrect = true;
                break;
            }
        }
        if (!isCorrect){
            return false;
        }
        paragraph.style.display = 'none';
        brother.style.display = 'block';
        return false;
    }

    function findParagraph(self){
        var ret = self;
        while (ret){
            ret = ret.parentNode
            if (ret.nodeName.toUpperCase() == 'P'){
                break;
            }
        }
        return ret;
    }
})();